package day01;

import java.util.Scanner;

/**
 * 要求用户从控制台输入一个email地址，然后获取该email的用户名(@之前的内容)
 * @author Bonnie
 *
 */
public class Test04 {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.println("请输入一个邮箱：");
		String email=input.next();
		int add=0;
		char[] ch=email.toCharArray();
		for (int i = 0; i < ch.length; i++) {
			if (ch[i]=='@'){
				add=i;break;
			}
			if(ch[i]!='@'&&i==ch.length-1) {
				System.out.println("邮箱格式错误！");
				System.exit(0);
			}
		}
		StringBuilder sb=new StringBuilder(email);
		System.out.println(sb.subSequence(0,add));
	}
}
